<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>监理服务系统</title>
    <!--layui样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/layui/css/layui.css"/>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/style.css"/>
    <!--扩展样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--auto-complete 自动选择文本css-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/layui/css/autocomplete.css"/>
    <!--Jquery-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <!--Jquery-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <style>
        .option {
            border: none;
        }

        .creatProject ul li label {
            width: 25%;
        }
    </style>
</head>
<body>
<!--容器-->
<div class="container clearfix">
    <form class="layui-form" id="myForm" style="width: 100%;" onkeydown="if(event.keyCode==13)return false;">
        <div class="fr mt20" style="width: 100%;">
            <!--创建项目-->
            <div class="creatProject whitebg">
                <div class="bold ft18">创建项目</div>
                <ul class="clearfix mt20">
                    <li class="clearfix">
                        <label class="fl">项目来源<span style="color: red">*</span></label>
                        <select class="fl" id="projectSource" name="projectSource" lay-verify="required"
                                onchange="_crt_page.events.sourceSelectChange(this)" lay-ignore>
                            <#list projectSourcelist?sort_by("badtCode") as vo>
                            <option value="${vo.badtCode}">${vo.badtName}</option>
                        </#list>
                        </select>
                    </li>
                    <li class="clearfix selectpro hide">
                        <label class="fl" style="width: 36%">选择项目(可选)</label>
                        <input type="text" name="keyword" id="oaselecttable" autocomplete="off">
                    </li>
                </ul>
            </div>
            <!--项目类型-->
            <div class="creatProject projectCate whitebg" style="margin-top: 20px;">
                <div class="bold ft18">项目类型</div>
                <ul class="clearfix mt20">
                    <li class="clearfix">
                        <label class="fl">项目类型<span style="color: red">*</span></label>
                        <select class="fl" id="projectType" name="projectType" lay-verify="notnull" lay-ignore>
                            <option value="">请选择</option>
                            <#list projectTypeList as pjtvo>
                            <option value="${pjtvo.badtCode}">${pjtvo.badtName}</option>
                        </#list>
                        </select>
                    </li>
                   <li class="clearfix">
                        <label class="fl">业务类型<span style="color: red">*</span></label>
                       <div style="display: flow-root;" class="fl wp42 h35">
                           <div class="slt" id="checkShape"></div>
                       </div>
                    </li>
                    <li class="clearfix">
                        <label class="fl">是否续签<span style="color: red">*</span></label>
                        <select class="fl" id="isContinue" name="isContinue" lay-verify="notnull" lay-ignore>
                            <option value="">请选择</option>
                            <#list isContinueList as icl>
                            <option value="${icl.badtCode}">${icl.badtName}</option>
                        </#list>
                        </select>
                    </li>
                </ul>
            </div>
            <!--项目信息-->
            <div class="creatProject projectData whitebg">
                <div class="bold ft18">项目信息</div>
                <ul class="clearfix mt20">
                    <li class="clearfix">
                        <label class="fl">项目名称<span style="color: red">*</span></label>
                        <input type="text" class="fl" id="projectName" name="projectName" lay-maxlength="80"
                               lay-verify="notnull|maxlength" placeholder="请填写项目名称">
                        <input type="hidden" name="id" id="projId">
                        <input type="hidden" id="htSignProvince">
                        <input type="hidden" id="htSignCity">
                        <input type="hidden" id="htSignCounty">
                        <input type="hidden" id="supProjectId" name="supProjectId">
                    </li>
                    <li class="clearfix">
                        <label class="fl">总工期<span style="color: red">*</span></label>
                        <input class="fl" name="totalDate" id="totalDate" op="1" AutoComplete="off"onchange="_crt_page.events.toDate2(this)"
                               style="width:125px;margin-left: 15px" lay-verify="required" placeholder="请填写项目工期"><span class="ml10 fl">日</span>
                        <input name="totalDurationBeginDate" class="fl test-item gq" op="0" zgq="start" type="datetime"  readonly="true"
                               id="totalDurationBeginDate"
                               AutoComplete="off" placeholder="请选择开始日期"
                               style="margin-left: 10px;width:123px"/><span class="fl">--</span>
                        <input class="fl" name="totalDurationEndDate" lay-verify="required" placeholder="结束日期" id="totalDurationEndDate" AutoComplete="off" readonly="true"
                               style="width:150px;margin-left: 15px" >
                    </li>
                    <li class="clearfix">
                        <label class="fl">投资额<span style="color: red">*</span></label>
                        <input type="text" class="fl" id="tzMoney" name="tzMoney" lay-maxlength="20"
                               lay-verify="required|decimal|maxlength" placeholder="请填写投资额">
                        <span class="fl">元</span>
                    </li>
                    <li class="clearfix">
                        <label class="fl">合同编号</label>
                        <input id="contractNo" name="contractNo" class="fl" lay-maxlength="128" type="text"
                               lay-verify="maxlength" placeholder="请填写合同编号"/>
                    </li>
                    <li class="clearfix">
                        <label class="fl" style="width: 29%">内部合同编号</label>
                        <input id="insideContractNo" placeholder="请填写内部合同编号" name="insideContractNo" class="fl" lay-maxlength="128" type="text"
                               lay-verify="maxlength" <#if (user.source) != '001'>disabled</#if>/>
                    </li>

                    <li class="clearfix">
                        <label class="fl" style="width: 20%;">采购/项目编号</label>
                        <input id="payOrProjectNo" name="payOrProjectNo" lay-maxlength="128" class="fl" type="text"
                               lay-verify="maxlength" placeholder="请填写采购/项目编号"/>
                    </li>
                    <li class="clearfix">
                        <label class="fl" style="width: 20%;">检测合同名称</label>
                        <input id="jlHtName" name="jlHtName" style="width: 60%;" class="fl" lay-maxlength="128"
                               type="text" lay-verify="maxlength" placeholder="请填写检测合同名称"/>
                    </li>
                    <li class="clearfix" style="width: 50%;">
                        <label class="fl" style="width: 20%;">项目归属<span style="color: red">*</span></label>
                        <select class="fl" id="projectOwner" name="projectOwner" style="margin-left: 10px;" lay-verify="required" lay-ignore>
                            <option value="">请选择</option>
                            <#list comlistOwner as vo>
                            <option value="${vo.bcId}">${vo.bcName}</option>
                        </#list>
                        </select>
                    </li>

                    <li class="clearfix" style="width: 50%;">
                        <label class="fl" style="width: 20%;">行业类型</label>
                        <select class="fl" id="hyType" name="hyType" lay-ignore style="margin-left: 10px;">
                            <option value="">请选择</option>
                            <#list hytypelist as vo>
                            <option value="${vo.badtCode}">${vo.badtName}</option>
                        </#list>
                        </select>
                    </li>
                <div class="layui-row">
                    <li class="clearfix" style="width: 50%;">
                        <label class="fl" style="width: 20%;">实施地点<span style="color: red">*</span></label>
                        <div class="address fl clearfix ssplace" style="width: 80%;">
                            <div class="clearfix mt10 divplaceselect">
                                <select name="projectPlacedtos[0].province" class="ml8 fl" id="placeprovince0"
                                        onchange="_crt_page.events.provinceChange(this)"
                                        style="width:90px !important;"
                                        lay-verify="required" lay-ignore>
                                    <option value="">请选择</option>
                                    <#list provincelist as vo>
                                    <option value="${vo.code}">${vo.name}</option>
                                </#list>
                                </select>
                                <select name="projectPlacedtos[0].city" id="placecity0" class="ml8 fl"
                                        lay-filter="city"
                                        onchange="_crt_page.events.cityChange(this)" lay-verify="required"
                                        style="width: 90px !important;margin-left: 10px" lay-ignore>
                                    <option value="">请选择</option>
                                </select>
                                <select name="projectPlacedtos[0].county" id="placecounty0" class="ml8 fl"
                                        lay-filter="county" lay-verify="required"
                                        style="width:90px !important;margin-left: 10px" lay-ignore>
                                    <option value="">请选择</option>
                                </select>
                                <img src="${re.contextPath}/plugin/common/images/77@2x.png" style="width: 28px;"
                                     class="fl ml20 addplaceimage" onclick="_crt_page.events.addPlace(this)">
                                <img src="${re.contextPath}/plugin/common/images/76@2x.png" style="width: 28px;"
                                     class="fl ml20"
                                     onclick="_crt_page.events.deletePlace(this)">
                            </div>
                        </div>

                    </li>
                    <li class="clearfix" style="width: 50%">
                        <label class="fl" style="width: 20%;">合同签订地点<span style="color: red">*</span></label>
                        <select name="province" class="ml8" id="province" style="width:90px !important;"
                                lay-verify="required" lay-ignore>
                            <option value="">请选择</option>
                            <#list provincelist as vo>
                            <option value="${vo.code}">${vo.name}</option>
                        </#list>
                        </select>
                        <select name="city" id="city" class="ml8" lay-filter="city" lay-verify="required"
                                style="width: 90px !important;margin-left: 0px" lay-ignore>
                            <option value="">请选择</option>
                        </select>
                        <select name="county" id="county" class="ml8" lay-filter="county" lay-verify="required"
                                style="width:100px !important;margin-left: 0px" lay-ignore>
                            <option value="">请选择</option>
                        </select>
                    </li>
                </div>
                    <#if (user.source) == '001'>
                        <div class="layui-row">
                            <li class="clearfix w30p">
                                <label class="fl w40p">是否需要招投标</label>
                                <select class="fl w40p" id="biddingRequired"
                                        onchange="_crt_page.events.toZhaoBiao(this)"
                                        name="biddingRequired" lay-ignore>
                                    <option value="">请选择</option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </li>
                            <li class="clearfix w30p">
                                <label class="fl" style="width: 35% !important;">是否已签合同</label>
                                <select class="fl w40p" id="hasContractSigned"
                                        onchange="_crt_page.events.toHetong(this)"
                                        name="hasContractSigned" lay-ignore>
                                    <option value="">请选择</option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </li>
                            <li class="clearfix w30p">
                                <label class="fl" style="width: 35% !important;">是否有首付款</label>
                                <select class="fl w40p" id="hasDownPayment" name="hasDownPayment" lay-ignore>
                                    <option value="">请选择</option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </li>

                        </div>
                        <div class="layui-row" style="float: left;width: 50%">
                            <li class="clearfix" id = "zhaobiaoDiv" style="width: 100%">
                                <label class="fl w35p" style="width: 20% !important;">是否已招标</label>
                                <select class="fl w45p" id="hasInviteBids" name="hasInviteBids" lay-ignore>
                                    <option value="">请选择</option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </li>
                        </div>
                        <div class="layui-row" id = "hetongDiv" style="width: 50%;float: left">
                            <li class="clearfix" style="width: 100%">
                                <label class="fl w40p" style="width: 20% !important;">合同签订时间</label>
                                <input name="contractSignTime" class="fl w40p pl10 gq" op="0" zgq="start" type="datetime"
                                       id="contractSignTime"  style="width: 50% !important;"
                                       AutoComplete="off" placeholder="请选择合同签订时间"/>
                            </li>
                        </div>
                    </#if>

                </ul>
            </div>
            <!--业主单位-->
            <div id="FZR" class="enterpriseUnit whitebg">
                <div class="clearfix">
                    <label class="fl">业主单位<span style="color: red">*</span></label>
                    <input type="text" class="fl" id="owerCompany" lay-maxlength="128" lay-verify="required|maxlength"
                           name="owerCompany" placeholder="请填写业主单位">
                </div>
                <div class="enterpriseUnitList">
                    <div class="bold ft18">项目负责人1<img src="${re.contextPath}/plugin/common/images/31@2x.png"
                                                      onclick="_crt_page.fzr.del(this)" alt="" class="fr cursor"
                                                      style="width:13px"></div>
                    <ul class="clearfix mt20">
                        <li class="clearfix">
                            <label class="fl w120">项目负责人<span style="color: red">*</span></label>
                            <input type="text" class="fl unit-ind-1" lay-maxlength="128"
                                   name="projectLeaders[0].realName" lay-verify="required|maxlength">
                            <input type="hidden" class="fl unit-ind-1" name="projectLeaders[0].projectLeader">
                        </li>
                        <li class="clearfix">
                            <label class="fl">职务<span style="color: red">*</span></label>
                            <input type="text" class="fl unit-ind-1" lay-maxlength="128" name="projectLeaders[0].duty"
                                   lay-verify="required|maxlength">
                        </li>
                    </ul>
                </div>
                <div class="center">
                    <button type="button" class="bluebg white bor0" id="btn_addfzr">添加</button>
                </div>
            </div>
            <!--业主单位-->
            <div id="BcUnit" class="enterpriseUnit whitebg">
                <div class="enterpriseUnitList">
                    <div class="bold ft18">承建单位1<img src="${re.contextPath}/plugin/common/images/31@2x.png"
                                                      onclick="_crt_page.fzr.del(this)" alt="" class="fr cursor"
                                                      style="width:13px"></div>
                    <ul class="clearfix mt20">
                        <li class="clearfix">
                            <label class="fl" style="width: 32%!important;">承建负责人<span style="color: red">*</span></label>
                            <input type="text" class="fl unit-ind-1" lay-maxlength="128"
                                   name="bcList[0].bcUnitNo" lay-verify="required|maxlength">
                            <input type="hidden" class="fl unit-ind-1" name="bcList[0].id">
                        </li>
                        <li class="clearfix">
                            <label class="fl">承建单位<span style="color: red">*</span></label>
                            <input type="text" class="fl unit-ind-1" lay-maxlength="128" name="bcList[0].bcUnit"
                                   lay-verify="required|maxlength">
                        </li>
                        <li class="clearfix">
                            <label class="fl"  style = "width:150px">被测合同/系统名称<span style="color: red">*</span></label>
                            <input type="text" class="fl unit-ind-1" lay-maxlength="128" name="bcList[0].bcHtName"
                                   lay-verify="required|maxlength">
                        </li>
                    </ul>
                </div>
                <div class="center">
                    <button type="button" class="bluebg white bor0" id="btn_addBcUnit">添加</button>
                </div>
            </div>
            <!--监理单位-->
            <div class="supervisionUnit whitebg">
                <ul class="clearfix">
                    <li class="clearfix">
                        <label class="fl">检测单位<span style="color: red">*</span></label>
                        <div style="display: flow-root;" class="fl wp42 h35">
                            <div class="slt" id="supervisorCompany"></div>
                        </div>
                    </li>
                    <li class="clearfix">
                        <label class="fl">项目经理<span style="color: red">*</span></label>
                        <div style="display: flow-root;" class="wp42 h3">
                            <div class="slt" id="projectManagerPerson"></div>
                        </div>
                    </li>
                    <li class="clearfix">
                        <label class="fl">检测工程师<span style="color: red">*</span></label>
                        <div style="display: flow-root;" class="fl wp42 h35">
                            <div class="slt" id="jcAdviser"></div>
                        </div>
                    </li>
                    <li class="clearfix">
                        <label class="fl">授权签字人<span style="color: red">*</span></label>
                        <div style="display: flow-root;" class="fl wp42 h35">
                            <div class="slt" id="industryPerson"></div>
                        </div>
                    </li>
                    <li class="clearfix">
                        <label class="fl">技术负责人<span style="color: red">*</span></label>
                        <div style="display: flow-root;" class="fl wp42 h35">
                            <div class="slt" id="technologyPerson"></div>
                        </div>
                    </li>
                    <li class="clearfix">
                        <label class="fl">检测合同额<span style="color: red">*</span></label>
                        <input type="text" class="fl" id="htMoney" name="htMoney" lay-maxlength=20"
                               lay-verify="required|decimal|maxlength"
                               onblur="_crt_page.events.displayMilepost(this)">
                        <span class="ml10 fl">元</span>
                    </li>
                </ul>
            </div>
            <!--阶段设置 里程碑进度占比-->
            <div class="stage clearfix" id="stagebox">
                <div class="stageLf whitebg fl">
                    <div class="bold ft18">阶段设置<span style="color: red">*</span></div>
                    <ul id="zbjd">
                    </ul>
                </div>
                <div class="stageRt whitebg fr" id="dvmilepost">
                    <div class="bold ft18">里程碑进度占比</div>
                </div>
            </div>
            <!--检测费付款方式-->
            <div class="payways whitebg">
                <li class="clearfix" style="width: 40%;">
                    <label class="fl">检测费付款方式<span style="color: red">*</span></label>
                    <select class="fl" id="fkfs" name="fkfs" lay-verify="required"   style="margin-left: 15px;"
                            onchange="_crt_page.events.toDate(this)" lay-ignore>
                        <option value="1">节点</option>
                        <option value="2">时间</option>
                    </select>
                </li>
                <table class="layui-hide" id="payways" lay-filter="payways"></table>
            </div>
            <!--提交-->
            <div class="createBtn clearfix">
                <button type="submit" lay-submit lay-filter="save" onclick="resetRequired()" class="bluebg white bor0 fl" id="btnsave">保存</button>
                <button type="submit" lay-submit lay-filter="submit" onclick="resetRequiredSubmit()" class="bluebg white bor0 fr" id="btnsubmit">提交
                </button>
            </div>
        </div>
    </form>
</div>
<!--layui JS-->
<script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js" charset="utf-8"></script>
<!--公用样式JS-->
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<!--启动JS-->
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/jquery.boot.js"></script>
<!--启动JS-->
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/jquery.common.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/layui/lay/modules/tableSelect.js"></script>

<#-- 可以多选的下拉框 -->
<script src="${re.contextPath}/plugin/layui/xm-select.js"></script>

<!-- 公共配置第三方组件 -->
<script type="text/javascript">
    layui.config({
        version: false,
        debug: false,
        base: "${re.contextPath}/plugin/layui/lay/extra/"
    })
</script>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <a class="layui-btn layui-btn-sm" lay-event="addrow">追加付款节点</a>
    </div>
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>


    var layer, form, laydate, autocomplete, table, biliTotal, tableSelect;

    var params = [{name: 1, value: "张三1sssss"}, {name: 2, value: "张三ssss2"}, {name: 3, value: "张三3sss"}, {
        name: 4,
        value: "张三4sssssssss"
    }, {name: 5, value: "张三sssss5"}];
    var _crt_page;
    var _gpakgs = [];
    var xmselectxmjl;
    var xmselectsqqzr;
    var xmselectjcgw;
    var xmselectsecondzjl;
    var xmselectjsfzr;
    var xmselectyw;
    var xmselectcompany;
    var fksj;
    var stamil=[];
    layui.use(['form', 'laydate', 'layer', 'autocomplete', 'tableSelect'], function () {
        laydate = layui.laydate;
        form = layui.form;
        tableSelect = layui.tableSelect;
        form.verify({
            maxlength: function (v, item) {
                var maxlength = item.getAttribute('lay-maxlength');
                if (v.trim() != '') {
                    if (v.trim().length > maxlength) {
                        return "输入长度不能大于" + maxlength + "个字符！";
                    }
                }
            },
            number: function (v) {
                if(v == ""){
                    return;
                }
                var reg = /^[0-9]*$/;
                var flag = reg.test(v.trim());
                if (!flag) {
                    return '请输入正确的数字';
                }
            },
            decimal: function (v) {
                if(v == ""){
                    return;
                }
                var reg = /^-?([0-9]+|[0-9]{1,3}(,[0-9]{3})*)(.[0-9]{1,10})?$/;
                var flag = reg.test(v.trim());
                if (!flag) {
                    return '请输入正确的金额';
                }
            },
            perdecimal: function (v) {
                if(v == ""){
                    return;
                }
                var reg = /^[1-9][0-9]*([.][0-9]+)?$/;
                var flag = reg.test(v.trim());
                if (!flag) {
                    if (v.trim() != "0" || v.trim() != 0) {
                        return '请输入数字';
                    }
                }
            },
            required: function(){

            },
            notnull: function(v,obj){
                if(v == ""){
                    var str =  $(obj).prev().text()
                    console.log(str)
                    return str+"必填项不能为空";
                }
            }
        })
        autocomplete = layui.autocomplete;
        _crt_page = {
            _init: function () {
                //初始化事件
                _crt_page.events._init();
                //forms初始化
                _crt_page.forms._init();
                //tables初始化
                _crt_page.tables._init();
            },
            forms: {
                _init: function () {
                    //初始化Form
                    form.on('submit(save)', _crt_page.forms.create);
                    form.on('submit(submit)', _crt_page.forms.submit);
                    form.on('checkbox(stage)', _crt_page.forms.checkbox.stageChange);
                    form.on('checkbox(milepost)', _crt_page.forms.checkbox.milepostChange);
                    //选择供需
                    _crt_page.forms.selectTableInit();
                    //日期初始化
                    _crt_page.forms.date._init();
                    //多选下拉初始化
                    _crt_page.forms.selects._init();
                    //初始化分包相关
                    /*_crt_page.packages._init();*/
                    //初始化负责人相关
                    _crt_page.fzr._init();
                    _crt_page.bcUnit._init();
                    //初始化AutoComplete
                    // _crt_page.forms._initAutoComplete();
                },
                checkbox: {
                    stageChange: function (data) {
                        if (data.elem.checked) {
                            $(data.elem).parent().find(".open").val("1");
                            $(data.elem).parent().find('.stagerq').attr('lay-verify', 'required');
                            var stageId = $(data.elem).parent().attr('stageid');
                            $(data.elem).parents('.stageLf').next().find('ul[pid=' + stageId + '] input[type=checkbox]').prop('checked', true);
                            $(data.elem).parents('.stageLf').next().find('ul[pid=' + stageId + '] .open').val('1');
                            form.render('checkbox');
                        } else {
                            $(data.elem).parent().find(".open").val("0");
                            //取消对应的开始时间,结束时间的校验:
                            $(data.elem).parent().find('.stagerq').removeAttr('lay-verify');
                            //把其下的所有里程取消选中:
                            var stageId = $(data.elem).parent().attr('stageid');
                            $(data.elem).parents('.stageLf').next().find('ul[pid=' + stageId + '] input[type=checkbox]').prop('checked', false);
                            $(data.elem).parents('.stageLf').next().find('ul[pid=' + stageId + '] .open').val('0');
                            form.render('checkbox');
                        }
                    },
                    milepostChange: function (data) {
                        if (data.elem.checked) {
                            //设置状态字段
                            $(data.elem).parent().find(".open").val("1");
                            //验证,如果选中了当前的里程碑,并且当前选中的里程碑为1,那么把当前阶段的checkbox选中:
                            var checkedMilepostLength = $(data.elem).parents('ul').find('.layui-form-checked').length;
                            if (checkedMilepostLength == 1) {
                                var stageId = $(data.elem).parents('ul').attr('pid');
                                var stageChecked = $("#zbjd").find('li[stageid=' + stageId + '] input[type=checkbox]').next().hasClass('layui-form-checked');
                                if (!stageChecked) {
                                    $("#zbjd").find('li[stageid=' + stageId + ']').find('input[type=checkbox]').click();
                                    $("#zbjd").find('li[stageid=' + stageId + ']').find('.open').val('1');
                                    $("#zbjd").find('li[stageid=' + stageId + ']').find('.stagerq').attr('lay-verify', 'required');
                                    form.render('checkbox');
                                }
                            }
                        } else {
                            $(data.elem).parent().find(".open").val("0");
                        }
                    }
                },
                date: {
                    _init: function () {
                        lay('.gq').each(function () {
                            var that = this;
                            laydate.render({
                                elem: this,
                                type: 'date',
                                trigger: 'click',
                                done: function (value, date) {

                                    var date = $("#totalDurationBeginDate").val();
                                    var code = $("#totalDate").val();
                                    console.log(date)
                                    if(code == null || code == "" || code == undefined){
                                        return;
                                    }
                                    var re = /^[0-9]*[1-9][0-9]*$/ ;
                                    if(!(re.test(code))){
                                        layer.msg("请输入正整数", {icon: 2});
                                        $(object).val("");
                                        return;
                                    }
                                    var day = DateDiff2(date,code);
                                    $("#totalDurationEndDate").val(day);
                                    $("#zbjd").find("li").last().find("#zbEndDate").val(day)
                                    $("#zbjd").find("li").first().find("#zbBeginDate").val(date)
                            }
                            });
                        });

                    }
                },
                totals: function () {
                    var stafecheckbox = $('#zbjd').find('li');
                    var milcheckbox = $('#dvmilepost').find('ul');
                    stafecheckbox.each(function (index, item) {
                        if ($(this).find('div.layui-form-checkbox').attr('class').indexOf('layui-form-checked') === -1) {
                            stamil[index].checkd = false
                        } else {
                            milcheckbox.each(function (i, t) {
                                if ($(this).attr('pid') === $(item).attr('stageid')) {
                                    var boxes = $(this).find('li .layui-form-checkbox')
                                    var val = $(this).find('li div input')
                                    val.each(function (a, b) {
                                        if ($(this).val()) {
                                            stamil[index].milepostlist[a].num = $(this).val()
                                        } else {
                                            stamil[index].milepostlist[a].num = 0
                                        }
                                    })
                                    boxes.each(function (x, m) {
                                        if ($(this).attr('class').indexOf('layui-form-checked') === -1) {
                                            stamil[index].milepostlist[x].checkd = false
                                        }
                                    })
                                }
                            })
                        }
                    })

                    var total, is_true;
                    is_true = true;
                    for (var i = 0; i < stamil.length; i++) {
                        console.log(stamil[i])
                        if (stamil[i].checkd) {
                            total = 0;
                            for (var m = 0; m < stamil[i].milepostlist.length; m++) {
                                if (stamil[i].milepostlist[m].checkd) {
                                    total += parseFloat(stamil[i].milepostlist[m].num)
                                }
                            }
                            if (total !== 100) {
                                is_true = false
                                $('#btnsubmit').removeClass("layui-btn-disabled").attr("disabled", false);
                                layer.msg(stamil[i].stagename + "的里程比例不等于100%", {icon: 2});
                                return false;
                            }
                        }
                    }
                    return is_true;
                },
                createbeforeBjy: function (data) {
                    var isTg = true;
                    var value = xmselectxmjl.getValue('valueStr');
                    if (!value) {
                        layer.msg("请选择项目经理", {icon: 2});
                        isTg = false;
                        return isTg;
                    }
                    var valueyw = xmselectyw.getValue('valueStr');
                    if (!valueyw) {
                        layer.msg("请选择业务类型", {icon: 2});
                        isTg = false;
                        return isTg;
                    }
                    $("#zbjd").find("[type=checkbox]:checked").each(function (i, v) {
                        var stageId = $(v).parent().attr("stageid");
                        var _mul = $("#dvmilepost").find("ul[pid=" + stageId + "]");
                        var open = $(_mul).find(".open");
                        var count = 0;
                        open.each(function (i, v) {
                            var value = $(v).attr("value");
                            if (value == "1") {
                                count++;
                            }
                        })
                    });
                    return isTg;
                },
                createbefore: function (data) {
                    var isTg = true;
                    var value = xmselectxmjl.getValue('valueStr');
                    if (!value) {
                        layer.msg("请选择项目经理", {icon: 2});
                        isTg = false;
                        return isTg;
                    }
                    var valuezjl = xmselectsqqzr.getValue('valueStr');
                    if (!valuezjl) {
                        layer.msg("请选择授权签字人", {icon: 2});
                        isTg = false;
                        return isTg;
                    }
                    var valuejfsz = xmselectjsfzr.getValue('valueStr');
                    if (!valuejfsz) {
                        layer.msg("请选择技术负责人", {icon: 2});
                        isTg = false;
                        return isTg;
                    }
                    var valueyw = xmselectyw.getValue('valueStr');
                    if (!valueyw) {
                        layer.msg("请选择业务类型", {icon: 2});
                        isTg = false;
                        return isTg;
                    }
                    var valuecom = xmselectcompany.getValue('valueStr');
                    if (!valuecom) {
                        layer.msg("请选择检测单位", {icon: 2});
                        isTg = false;
                        return isTg;
                    }

                    $("#zbjd").find("[type=checkbox]:checked").each(function (i, v) {
                        var stageId = $(v).parent().attr("stageid");
                        var _mul = $("#dvmilepost").find("ul[pid=" + stageId + "]");
                        var open = $(_mul).find(".open");
                        var count = 0;
                        open.each(function (i, v) {
                            var value = $(v).attr("value");
                            if (value == "1") {
                                count++;
                            }
                        })
                        if (count == 0) {
                            var jdname = $(v).parent().find("span").html();
                            layer.msg(jdname + "，必须选择一个里程节点", {icon: 2});
                            isTg = false;
                            return isTg;
                        }
                    });
                    return isTg;
                },
                create: function (data) {
                    console.log("保存中...");
                    /*按钮至灰色不能用，防止重复提交*/
                    $('#btnsave').addClass("layui-btn-disabled").attr("disabled", true);
                    var _pay_data = _crt_page.tables.getTableDataBjy(data);
                    data.field.status = '001';
                    var istg = _crt_page.forms.createbeforeBjy(data);
                    if (istg && _pay_data) {
                        data.field.projectManagerPerson = xmselectxmjl.getValue('valueStr');
                        data.field.industryPerson = xmselectsqqzr.getValue('valueStr');
                        data.field.jcAdviser = xmselectjcgw.getValue('valueStr');
                        data.field.supervisorCompany = xmselectcompany.getValue('valueStr');
                        data.field.technologyPerson = xmselectjsfzr.getValue('valueStr');
                        data.field.checkShape = xmselectyw.getValue('valueStr');
                        layerAjax('/jc/projectCreate/createsave', data.field, '', function (d) {
                            if (d.flag == true) {
                                layer.msg(d.msg, {icon: 1});
                                setTimeout(tzym,2000);
                            } else {
                                layer.msg(d.msg, {icon: 2});
                            }
                        });
                    }
                    setTimeout(function () {
                        $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                    }, 5000);
                    return false;
                },
                submit: function (data) {

                    /*按钮至灰色不能用，防止重复提交*/
                    $('#btnsubmit').addClass("layui-btn-disabled").attr("disabled", true);
                    var _pay_data = _crt_page.tables.getTableData(data);
                    // 验证里程 的100%  必须要达到100%
                    var isyz=_crt_page.forms.totals();
                    if(!isyz){
                        $('#btnsubmit').removeClass("layui-btn-disabled").attr("disabled", false);
                        return false ;
                    }
                    data.field.status = '002';
                    if (biliTotal != '100%') {
                        layer.msg("付款比例不等于100%", {icon: 2});
                        $('#btnsubmit').removeClass("layui-btn-disabled").attr("disabled", false);
                        return false;
                    }
                    var jd=$("#zbjd").find('li').length;
                    if(jd > 0 && jd == 1){
                        if(data.field["jcProjectStages[0].endDate"]<data.field["jcProjectStages[0].startDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("结束时间不能小于最后阶段的起始时间",{icon:2});
                            return false;
                        }
                    }else if(jd==2) {
                        if(data.field["jcProjectStages[0].endDate"]<data.field["jcProjectStages[0].startDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("结束时间不能小于最后阶段的起始时间",{icon:2});
                            return false;
                        }
                        if(data.field["jcProjectStages[1].endDate"]<data.field["jcProjectStages[1].startDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("结束时间不能小于最后阶段的起始时间",{icon:2});
                            return false;
                        }
                    }else if(jd==3){
                        if(data.field["jcProjectStages[0].endDate"]<data.field["jcProjectStages[0].startDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("结束时间不能小于最后阶段的起始时间",{icon:2});
                            return false;
                        }
                        if(data.field["jcProjectStages[0].startDate"]>data.field["jcProjectStages[1].endDate"]||data.field["jcProjectStages[1].endDate"]>data.field["jcProjectStages[2].endDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("阶段时间不在总工期内",{icon:2});
                            return false;
                        }
                        if(data.field["jcProjectStages[2].endDate"]<data.field["jcProjectStages[2].startDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("结束时间不能小于最后阶段的起始时间",{icon:2});
                            return false;
                        }

                    }else if(jd==4){
                        if(data.field["jcProjectStages[0].endDate"]<data.field["jcProjectStages[0].startDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("结束时间不能小于最后阶段的起始时间",{icon:2});
                            return false;
                        }
                        if(data.field["jcProjectStages[0].startDate"]>data.field["jcProjectStages[1].endDate"]||data.field["jcProjectStages[1].endDate"]>data.field["jcProjectStages[3].endDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("阶段时间不在总工期内",{icon:2});
                            return false;
                        }
                        if(data.field["jcProjectStages[0].startDate"]>data.field["jcProjectStages[2].endDate"]||data.field["jcProjectStages[2].endDate"]>data.field["jcProjectStages[3].endDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("结束时间不能小于最后阶段的起始时间",{icon:2});
                            return false;
                        }
                        if(data.field["jcProjectStages[3].endDate"]<data.field["jcProjectStages[3].startDate"]){
                            $('#btnsave').removeClass("layui-btn-disabled").attr("disabled", false);
                            layer.msg("结束时间不能小于最后阶段的起始时间",{icon:2});
                            return false;
                        }
                    }
                    var istg = _crt_page.forms.createbefore(data);
                    if (istg && _pay_data  && isyz) {
                        data.field.projectManagerPerson = xmselectxmjl.getValue('valueStr');
                        data.field.industryPerson = xmselectsqqzr.getValue('valueStr');
                        data.field.jcAdviser = xmselectjcgw.getValue('valueStr');
                        data.field.supervisorCompany = xmselectcompany.getValue('valueStr');
                        data.field.technologyPerson = xmselectjsfzr.getValue('valueStr');
                        data.field.checkShape = xmselectyw.getValue('valueStr');
                        layerAjax('/jc/projectCreate/createsave', data.field, '', function (d) {
                            if (d.flag == true) {
                                layer.msg(d.msg, {icon: 1});
                                setTimeout(tzym,2000);
                            } else {
                                layer.msg(d.msg, {icon: 2});
                            }
                        });
                    }
                    setTimeout(function () {
                        $('#btnsubmit').removeClass("layui-btn-disabled").attr("disabled", false);
                    }, 5000);
                    return false;
                },
                selects: {
                    _init: function () {
                        _crt_page.forms.selects._intSlt(0, 'slt');
                        //监理单位
                        /*  $("#supervisorCompany").change(_crt_page.forms.selects.companychange);*/
                    },
                    _intSlt: function (a, b, c, d) {
                        var supProjectId = $("#supProjectId").val();
                        if (!supProjectId) {
                            //项目经理绑定下拉
                            var xmjlry = [];
                            xmselectxmjl = xmSelect.render({
                                el: '#projectManagerPerson',
                                filterable: true,
                                radio: true,
                                toolbar: {show: true},
                                layVerType: 'msg',
                                data: xmjlry
                            });
                            var yw = [];
                            xmselectyw = xmSelect.render({
                                el: '#checkShape',
                                filterable: true,
                                toolbar: {show: true},
                                layVerType: 'msg',
                                data: yw
                            });
                            var sqqzr = [];
                            xmselectxmjl = xmSelect.render({
                                el: '#industryPerson',
                                filterable: true,
                                radio: true,
                                toolbar: {show: false},
                                layVerType: 'msg',
                                data: sqqzr
                            });
                            var jsfzr = [];
                            xmselectxmjl = xmSelect.render({
                                el: '#technologyPerson',
                                filterable: true,
                                radio: true,
                                toolbar: {show: false},
                                layVerType: 'msg',
                                data: jsfzr
                            });
                            var jcgw = [];
                            xmselectjcgw = xmSelect.render({
                                el: '#jcAdviser',
                                filterable: true,
                                radio: true,
                                toolbar: {show: false},
                                layVerType: 'msg',
                                data: jcgw
                            });
                            layerAjaxGet("/jc/projectCreate/getCompany", {}, "", function (d) {
                                var rows = null;
                                if (d.flag) {
                                    if (d.data) {
                                        rows = d.data;
                                    }
                                    if (rows) {
                                        var _ycols = ['bcId', 'bcName'];
                                        var companysz = [];
                                        $.each(rows, function (i, v) {
                                            companysz.push({name: v[_ycols[1]], value: v[_ycols[0]]});
                                        })
                                        // 绑定技术负责人下拉
                                        xmselectcompany = xmSelect.render({
                                            el: '#supervisorCompany',
                                            filterable: true,
                                            radio: true,
                                            toolbar: {show: false},
                                            clickClose:true,
                                            layVerType: 'msg',
                                            on: function (data) {
                                                if (data && data.arr.length > 0) {
                                                    _crt_page.forms.selects.companychange(data.arr[0].value);
                                                }

                                            },
                                            data: companysz
                                        })
                                    }
                                }

                            });
                        }


                    },
                    deleteSelect: function (id, selectclass) {
                        $(id).find(selectclass).each(function (i, v) {
                            var title = $(v).find(".label-content").attr("title");
                            if (title) {
                                var arrselect = title.split(',');
                                for (var y = 0; y < arrselect.length; y++) {
                                    for (var i = 0; i < _gpakgs.length; i++) {
                                        var selectele = _gpakgs[i];
                                        var pavalue = selectele.value;
                                        if (arrselect[y].indexOf(pavalue) != -1) {
                                            _gpakgs.splice(i, 1)
                                        }
                                    }
                                }
                            }

                        });

                    },
                    companychange: function (_comid) {
                        var _comid = _comid;
                        if (_comid) {
                            var _ycols = ['id', 'realName'];
                            layerAjaxGet("/user/getdicts", {companyName: _comid, userRole: 'jcjsfzr'}, "", function (d) {
                                var rows = null;
                                if (d.code == 200) {
                                    if (d.data) {
                                        rows = d.data;
                                    }
                                    if (rows) {
                                        var jsfzr = [];
                                        $.each(rows, function (i, v) {
                                            if (i == 0) {
                                                jsfzr.push({name: v[_ycols[1]], value: v[_ycols[0]], selected: true});
                                            } else {
                                                jsfzr.push({name: v[_ycols[1]], value: v[_ycols[0]]});
                                            }
                                        })
                                        // 绑定技术负责人下拉
                                        xmselectjsfzr = xmSelect.render({
                                            el: '#technologyPerson',
                                            filterable: true,
                                            radio: true,
                                            clickClose:true,
                                            toolbar: {show: false},
                                            layVerType: 'msg',
                                            data: jsfzr
                                        })
                                    }
                                }

                            });

                            layerAjaxGet("/user/getdicts", {companyName: _comid, userRole: 'sqqzr'}, "", function (d) {
                                var rows = null;
                                if (d.code == 200) {
                                    if (d.data) {
                                        rows = d.data;
                                    }
                                    if (rows) {
                                        var sqqzr = [];
                                        $.each(rows, function (i, v) {
                                            if (i == 0) {
                                                sqqzr.push({name: v[_ycols[1]], value: v[_ycols[0]], selected: true});
                                            } else {
                                                sqqzr.push({name: v[_ycols[1]], value: v[_ycols[0]]});
                                            }

                                        })
                                        // 绑定授权签字人
                                        xmselectsqqzr = xmSelect.render({
                                            el: '#industryPerson',
                                            filterable: true,
                                            radio: true,
                                            clickClose:true,
                                            toolbar: {show: false},
                                            layVerType: 'msg',
                                            data: sqqzr
                                        })
                                    }
                                }

                            });
                            layerAjaxGet("/user/getdicts", {companyName: _comid, userRole: 'jcgw'}, "", function (d) {
                                var rows = null;
                                if (d.code == 200) {
                                    if (d.data) {
                                        rows = d.data;
                                    }
                                    if (rows) {
                                        var jcgw = [];
                                        $.each(rows, function (i, v) {
                                            if (i == 0) {
                                                jcgw.push({name: v[_ycols[1]], value: v[_ycols[0]], selected: true});
                                            } else {
                                                jcgw.push({name: v[_ycols[1]], value: v[_ycols[0]]});
                                             }
                                        })
                                        console.log(jcgw);
                                        // 绑定检测顾问下拉
                                        xmselectjcgw = xmSelect.render({
                                            el: '#jcAdviser',
                                            filterable: true,
                                            toolbar: {show: false},
                                            layVerType: 'msg',
                                            data: jcgw
                                        })
                                    }
                                }

                            });
                            layerAjaxGet("/user/getdicts", {companyName: _comid, userRole: 'jcxmjl'}, "", function (d) {
                                var rows = null;
                                if (d.code == 200) {
                                    if (d.data) {
                                        rows = d.data;
                                    }
                                    if (rows) {
                                        var xmjlry = [];
                                        $.each(rows, function (i, v) {
                                            console.log(rows);
                                            if (v[_ycols[0]] == "${currId}") {
                                                xmjlry.push({name: v[_ycols[1]], value: v[_ycols[0]], selected: true});
                                            } else {
                                                xmjlry.push({name: v[_ycols[1]], value: v[_ycols[0]]});
                                            }
                                        })
                                        // 绑定项目经理下拉
                                        xmselectxmjl = xmSelect.render({
                                            el: '#projectManagerPerson',
                                            filterable: true,
                                            radio: true,
                                            disabled: true,
                                            toolbar: {show: true},
                                            layVerType: 'msg',
                                            data: xmjlry
                                        })
                                    }
                                }

                            });
                        } else {
                            var jsfzr = [];
                            xmselectjsfzr.update({data: jsfzr});
                            var sqqzr = [];
                            xmselectsqqzr.update({data: sqqzr});
                            // var secondjlgcs = [];
                            // xmselectsecondzjl.update({data: secondjlgcs});
                            var xmjlry = [];
                            xmselectxmjl.update({data: xmjlry});
                            var jcgw = [];
                            xmselectjcgw.update({data: jcgw});

                        }
                    }
                },
                _initAutoComplete: function () {
                    autocomplete.render({
                        elem: $('#supervisorCompanyText'),
                        url: '/sys/base/comdict',
                        response: {code: 'code', data: 'data'},
                        // params: function () {return { bcName:'JLDW001'};},
                        statusCode: 0,
                        template_val: '{{d.bcName}}',
                        template_txt: '{{d.bcName}}',
                        onselect: function (resp) {
                            var _comid = resp.bcId;
                            $('#supervisorCompany').val(_comid);
                            var _ycols = ['id', 'realName'];
                            $("#technologyPerson").initSelect('/user/getdicts', {
                                companyname: _comid,
                                userRole: 'jcjsfzr'
                            }, _ycols);
                            $("#industryPerson").initSelect('/user/getdicts', {
                                companyname: _comid,
                                userRole: 'sqqzr'
                            }, _ycols);
                            $("#jcAdviser").initSelect('/user/getdicts', {
                                companyname: _comid,
                                userRole: 'jcgw'
                            }, _ycols);
                            $("#projectManagerPerson").initSelect('/user/getdicts', {
                                companyname: _comid,
                                userRole: 'jcxmjl'
                            }, _ycols);
                        }
                    });
                },
                selectTableInit: function () {

                    tableSelect.render(
                        {
                            elem: '#oaselecttable',
                            searchKey: 'keyword',
                            searchPlaceholder: '项目名称搜索',
                            table: {
                                url: '/jc/projectManager/showProjectGxList',
                                cols: [
                                    [
                                        {type: 'radio'}
                                        , {field: 'supProjectId', hide: true}
                                        , {field: 'projectName', title: '项目名称', width: '70%', align: 'center'},
                                        {
                                            field: 'projectType',
                                            title: '项目类型',
                                            width: '30%',
                                            sort: true,
                                            templet: function (d) {
                                                var typestr = [];
                                                var type = d.projectType;
                                                if (type) {
                                                    if (type.indexOf("001") > -1) {
                                                        typestr.push("监理");
                                                    }
                                                    if (type.indexOf("002") > -1) {
                                                        typestr.push("咨询");
                                                    }
                                                    if (type.indexOf("003") > -1) {
                                                        typestr.push("检测");
                                                    }
                                                    if (type.indexOf("004") > -1) {
                                                        typestr.push("其他");
                                                    }
                                                    typestr = typestr.join(",");
                                                }
                                                return typestr;
                                            }
                                        },
                                        {field: 'createDate', title: '发布时间', width: '40%', sort: true},
                                        {field: 'gqBeginDate', title: '总工期开始时间', width: '30%', hide: false, sort: true},
                                        {field: 'gqEndDate', title: '总工期结束时间', width: '30%', hide: false, sort: true},
                                        {field: 'tzMoney', title: '项目建设总投资额', width: '30%', hide: true, sort: true},
                                        {field: 'htSignCity', title: '合同签订地点（市）', width: '30%', hide: true, sort: true},
                                        {
                                            field: 'htSignProvince',
                                            title: '合同签订地点（省）',
                                            width: '30%',
                                            hide: true,
                                            sort: true
                                        },
                                        {
                                            field: 'htSignCounty',
                                            title: '合同签订地点（县）',
                                            width: '30%',
                                            hide: true,
                                            sort: true
                                        },
                                        {field: 'zbCompany', title: '中标单位）', width: '30%', hide: true, sort: true},
                                        {field: 'companyName', title: '发布单位名称', width: '30%', hide: true, sort: true},
                                        {field: 'jcFwMoney', title: '检测服务费', width: '30%', hide: true, sort: true},
                                        {field: 'contractNo', title: '合同编号', width: '30%', hide: true, sort: true},
                                        {
                                            field: 'projectLeader',
                                            title: '业主单位负责人',
                                            width: '30%',
                                            hide: true,
                                            sort: true
                                        },
                                        {field: 'duty', title: '业主单位负责人职务', width: '30%', hide: true, sort: true},


                                    ]
                                ],
                                done: function (res, currentCount) {
                                    //***重点***：table渲染完成后渲染element进度条
                                    $(".layui-anim-upbit").css("width", "80%");
                                    $(".layui-anim-upbit").css("left", "0px");
                                    $(".layui-anim-upbit").css("margin", "0px 0px 0px 200px");

                                }
                            },
                            done: function (elem, data) {

                                var NEWJSON = [];
                                layui.each(data.data, function (index, item) {
                                    var supProjectId = item.supProjectId;
                                    $("#supProjectId").val(supProjectId);
                                    var projectName = item.projectName;
                                    $("#oaselecttable").val(projectName);
                                    $("#projectName").val(projectName);
                                    var tzMoney = item.tzMoney;
                                    $("#tzMoney").val(tzMoney);
                                    //　合同签订地点对应供需的合同签订地点，不可修改
                                    var htSignProvince = item.htSignProvince;
                                    var htSignCity = item.htSignCity;
                                    var htSignCounty = item.htSignCounty;
                                    $("#htSignProvince").val(htSignProvince);
                                    $("#projectOwner").val(item.projectOwner);
                                    $('#province option').each(function (i, v) {
                                        if ($(v).attr("value") == htSignProvince) {
                                            $(v).attr("selected", true);
                                        }
                                    });
                                    $("#htSignCounty").val(htSignCounty);
                                    $("#htSignCity").val(htSignCity);
                                    _crt_page.events.provinceval();
                                    setTimeout(function () {
                                        _crt_page.events.cityval();
                                    }, 2000);
                                    // 业主单位
                                    var companyName = item.owerCompany;
                                    if (companyName) {
                                        $("#owerCompany").val(companyName)
                                    }
                                    var hyType = item.hyType;
                                    if (hyType) {
                                        $("#hyType").val(hyType)
                                    }
                                    // 中标单位--监理单位
                                    var zbCompany = item.zbCompany;
                                    // 检测服务费
                                    var jcFwMoney = item.jcFwMoney;
                                    $("#htMoney").val(jcFwMoney);
                                    //是否已签订合同
                                    var qdHt = item.qdHt;
                                    //是否已投标
                                    var isZb = item.isZb;
                                    //是否有首付款
                                    var isSfk = item.isSfk;
                                    //是否需要投标
                                    var needZb = item.needZb;
                                    var htSignDate = item.htSignDate;
                                    if (needZb) {
                                        $("#biddingRequired").find("option").each(function (i, v) {
                                            if ($(v).attr("value") == needZb) {
                                                $(v).attr("selected", true);
                                            }
                                        });
                                    }
                                    if (isZb) {
                                        $("#hasInviteBids").find("option").each(function (i, v) {
                                            if ($(v).attr("value") == isZb) {
                                                $(v).attr("selected", true);
                                            }
                                        });
                                    }
                                    if (qdHt) {
                                        $("#hasContractSigned").find("option").each(function (i, v) {
                                            if ($(v).attr("value") == qdHt) {
                                                $(v).attr("selected", true);
                                            }
                                        });
                                    }
                                    if (isSfk) {
                                        $("#hasDownPayment").find("option").each(function (i, v) {
                                            if ($(v).attr("value") == isSfk) {
                                                $(v).attr("selected", true);
                                            }
                                        });
                                    }
                                    if (htSignDate) {
                                        $("#contractSignTime").val(htSignDate.substr(0, 10));
                                    }
                                    var contractNo = item.contractNo;
                                    var insideContractNo = item.insideContractNo;
                                    if (contractNo) {
                                        $("#contractNo").val(contractNo);
                                    }
                                    if(insideContractNo){
                                        $("#insideContractNo").val(insideContractNo);
                                    }

                                    var jlHtName = item.jlHtName;
                                    if (jlHtName) {
                                        $("#jlHtName").val(jlHtName);
                                    }
                                    var payOrProjectNo = item.payOrProjectNo;
                                    if (payOrProjectNo) {
                                        $("#payOrProjectNo").val(payOrProjectNo);
                                    }
                                    // 监理方式
                                    var checkShape = item.checkShape;
                                    if (checkShape) {
                                        $("#checkShape").find("option").each(function (i, v) {
                                            if ($(v).attr("value") == checkShape) {
                                                $(v).attr("selected", true);
                                            }
                                        });
                                    }
                                    var palaces = item.projectPlacedtos;
                                    _crt_page.events.gxPlaceInit(palaces);

                                    // 业主单位
                                    var projectLeader = item.projectLeader;
                                    if (projectLeader) {
                                        $("[name='projectLeaders[0].realName']").val(projectLeader);
                                    }
                                    var duty = item.duty;
                                    if (duty) {
                                        $("[name='projectLeaders[0].duty']").val(duty);
                                    }
                                    layerAjaxGet("/supervisor/projectManager/getCompany", {}, "", function (d) {
                                        var rows = null;
                                        if (d.flag) {
                                            if (d.data) {
                                                rows = d.data;
                                            }
                                            if (rows) {
                                                var _ycols = ['bcId', 'bcName'];
                                                var companysz = [];
                                                $.each(rows, function (i, v) {
                                                    if (v[_ycols[0]] == zbCompany) {
                                                        companysz.push({
                                                            name: v[_ycols[1]],
                                                            value: v[_ycols[0]],
                                                            selected: true
                                                        });
                                                    } else {
                                                        companysz.push({name: v[_ycols[1]], value: v[_ycols[0]]});
                                                    }
                                                })

                                                xmselectcompany.update({data: companysz});
                                                _crt_page.forms.selects.companychange(zbCompany);
                                            }
                                        }

                                    });
                                    var jlManagerPerson = item.jlManagerPerson;
                                    if (jlManagerPerson) {
                                        setTimeout(function () {
                                            var _ycols = ['id', 'realName'];
                                            layerAjaxGet("/user/getdicts", {
                                                companyName: zbCompany,
                                                userRole: 'xmjl'
                                            }, "", function (d) {
                                                var rows = null;
                                                if (d.code == 200) {
                                                    if (d.data) {
                                                        rows = d.data;
                                                    }
                                                    if (rows) {
                                                        var xmjlry = [];
                                                        $.each(rows, function (i, v) {
                                                            if (v[_ycols[0]] == jlManagerPerson) {
                                                                xmjlry.push({
                                                                    name: v[_ycols[1]],
                                                                    value: v[_ycols[0]],
                                                                    selected: true
                                                                });
                                                            } else {
                                                                xmjlry.push({name: v[_ycols[1]], value: v[_ycols[0]]});
                                                            }
                                                        })
                                                        // 绑定项目经理下拉
                                                        xmselectxmjl = xmSelect.render({
                                                            el: '#projectManagerPerson',
                                                            filterable: true,
                                                            radio: true,
                                                            toolbar: {show: true},
                                                            layVerType: 'msg',
                                                            data: xmjlry
                                                        })
                                                    }
                                                }

                                            });

                                        }, 1000);


                                    }


                                })
                            }
                        })

                    $(".layui-anim-upbit").css("width", "80%");
                    $(".layui-anim-upbit").css("left", "0px");


                },
            },
            tables: {
                _init: function () {
                    _crt_page.tables.renderTable(false,true);
                },
                renderTable: function (fkjd,fksj) {
                    var fksj=fksj;
                    layui.use(['table'], function () {
                         table = layui.table;
                        var cols = table.render({
                            elem: '#payways',
                            id: 'payways',
                            cellMinWidth: 80,
                            totalRow: true,
                            toolbar: '#toolbarDemo',
                            defaultToolbar: false,
                            height: '300px',
                            cols: [[
                                // {type: 'checkbox', fixed: 'left'},
                                {
                                    field: 'sppNo',
                                    align: 'center',
                                    title: '付款次数',
                                    edit: 'text',
                                    totalRowText: '合计',
                                    width: 100
                                },
                                {field: 'sppNode', align: 'center', title: '付款节点', minWidth: 120, hide: true},
                                {field: 'nodeOrder', align: 'center', title: '里程序号', minWidth: 120, hide: true},
                                {field: 'milepostName', align: 'center', title: '付款节点<span style="color: red">*</span>', minWidth: 120, event: 'node',hide: fkjd},
                                {field: 'payDate', align: 'center', title: '付款时间<span style="color: red">*</span>', minWidth: 120,hide: fksj,event: 'editStartDate'},
                                {
                                    field: 'sppPersent',
                                    align: 'center',
                                    title: '付款比例<span style="color: red">*</span>',
                                    edit: 'text',
                                    totalRow: true,
                                    width: 200,
                                    event: 'persent'
                                },
                                {
                                    field: 'payMoney',
                                    align: 'center',
                                    title: '付款金额<span style="color: red">*</span>',
                                    totalRow: true,
                                    width: 200
                                },
                                {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150}
                            ]],
                            data: [
                                {
                                    "sppId": "",
                                    "sppNo": "1",
                                    "sppNode": "",
                                    "nodeOrder": "",
                                    "milepostName": "",
                                    "payDate": "",
                                    "sppPersent": "20%",
                                    "payMoney": ""
                                }
                            ],
                            done: function (res, curr, count) {
                                 $(".layui-input-date").each(function (i) {
                                     layui.laydate.render({
                                         elem: this,
                                         format: "yyyy-MM-dd",
                                         trigger: 'click',
                                         done: function (value, date) {
                                         }
                                     });

                                 });
                                /*处理合计*/
                                var totaldiv = $(".layui-table-total").find("tbody").find("td:eq(5)").find("div");
                                var totalsz = totaldiv.html();
                                totaldiv.html(parseFloat(totalsz) + "%");
                                biliTotal = parseFloat(totalsz) + "%";
                            }
                        }).config.cols;
                         //监听单元格事件
                        table.on('tool(payways)', _crt_page.tables.events.tool);
                        //监听单元格编辑
                        table.on('edit(payways)', _crt_page.tables.events.edit);
                        //头工具栏事件
                        table.on('toolbar(payways)', _crt_page.tables.events.toolbar);
                    });
                },
                getTableDataBjy: function (data) {
                    var  fileData=data.field;
                    for(var x in fileData){
                        // 因为业主负责人和承建单位的下拉列表 是 name 是随机生成的数字 这里要 删除后重新赋值
                        if(x.indexOf("projectLeaders")>-1  && x.indexOf("leaderFbNumber")>-1  ){
                            delete fileData[x];
                        }
                        if(x.indexOf("projectUnitConstructions")>-1  && x.indexOf("constructionSubContractNumber")>-1  ){
                            delete fileData[x];
                        }
                    }
                    var tabledata = layui.table.cache.payways;
                    var _aln = tabledata.length;
                    data.field.sppNo = [];
                    data.field.fkfs = fkfs;
                    data.field.sppNode = [];
                    data.field.sppPersent = [];
                    data.field.payDate = [];
                    data.field.nodeOrder = [];
                    data.field.payMoney = [];
                    for (var i = 0; i < _aln; i++) {
                        var _itm = tabledata[i];
                        console.log(_itm)
                        var fkfs = $("select#fkfs.fl").val();
                        data.field.fkType = fkfs;
                        data.field['payList[' + i + '].sppNo'] = _itm.sppNo;
                        data.field['payList[' + i + '].sppNode'] = _itm.sppNode;
                        data.field['payList[' + i + '].sppPersent'] = _itm.sppPersent;
                        data.field['payList[' + i + '].payDate'] = _itm.payDate;
                        data.field['payList[' + i + '].payMoney'] = _itm.payMoney;
                        data.field['payList[' + i + '].nodeOrder'] = _itm.nodeOrder;
                    }
                    // 对选择的下拉列表 选项重新排序
                    $("#FZR .enterpriseUnitList").find(".xm-select-default").each(function (i,v) {
                        data.field['projectLeaders[' + i + '].leaderFbNumber']=$(v).val();
                    })
                    $("#CJDW .constructionUnit").find(".xm-select-default").each(function (i,v) {
                        data.field['projectUnitConstructions[' + i + '].constructionSubContractNumber']=$(v).val();
                    })
                    return true;
                },
                getTableDataBjy: function (data) {
                    var tabledata = layui.table.cache.payways;
                    var _aln = tabledata.length;
                    data.field.sppNo = [];
                    data.field.fkfs = fkfs;
                    data.field.sppNode = [];
                    data.field.sppPersent = [];
                    data.field.payDate = [];
                    data.field.nodeOrder = [];
                    data.field.payMoney = [];
                    for (var i = 0; i < _aln; i++) {
                        var _itm = tabledata[i];
                        console.log(_itm)
                        var fkfs = $("select#fkfs.fl").val();
                        data.field.fkType = fkfs;
                        data.field['payList[' + i + '].sppNo'] = _itm.sppNo;
                        data.field['payList[' + i + '].sppNode'] = _itm.sppNode;
                        data.field['payList[' + i + '].sppPersent'] = _itm.sppPersent;
                        data.field['payList[' + i + '].payDate'] = _itm.payDate;
                        data.field['payList[' + i + '].payMoney'] = _itm.payMoney;
                        data.field['payList[' + i + '].nodeOrder'] = _itm.nodeOrder;
                    }
                    return true;
                },
                getTableData: function (data) {
                    var tabledata = layui.table.cache.payways;
                    var _aln = tabledata.length;
                    data.field.sppNo = [];
                    data.field.fkfs = fkfs;
                    data.field.sppNode = [];
                    data.field.sppPersent = [];
                    data.field.payDate = [];
                    data.field.nodeOrder = [];
                    data.field.payMoney = [];
                    for (var i = 0; i < _aln; i++) {
                        var _itm = tabledata[i];
                        console.log(_itm)
                        var fkfs = $("select#fkfs.fl").val();
                        data.field.fkType = fkfs;
                        if(fkfs == "1"){
                            if (!_itm.sppNode || !_itm.sppPersent) {
                                layer.msg("付款节点或付款比例不能为空", {icon: 2});
                                return false;
                            }
                        }else{
                            if (!_itm.payDate) {
                                layer.msg("付款时间或付款比例不能为空", {icon: 2});
                                return false;
                            }
                        }
                        if(i>0){
                            console.log(_itm.payDate<tabledata[i-1].payDate)
                           if(_itm.payDate<tabledata[i-1].payDate){
                               layer.msg("后面的付款时间不能低于前面的付款时间", {icon: 2});
                               return false;
                           }
                        }
                        data.field['payList[' + i + '].sppNo'] = _itm.sppNo;
                        data.field['payList[' + i + '].sppNode'] = _itm.sppNode;
                        data.field['payList[' + i + '].sppPersent'] = _itm.sppPersent;
                        data.field['payList[' + i + '].payDate'] = _itm.payDate;
                        data.field['payList[' + i + '].payMoney'] = _itm.payMoney;
                        data.field['payList[' + i + '].nodeOrder'] = _itm.nodeOrder;
                    }
                    return true;
                },
                events: {
                    tool: function (obj) {
                        var fksj=fksj;
                        var data = obj.data;
                        switch (obj.event) {
                            case 'node':
                                layer.open({
                                    title: '请选择付款节点',
                                    content: _crt_page.stages.getmilestoneselects(), //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                                    yes: function (index, layero) {
                                        //如果设定了yes回调，需进行手工关闭
                                        layer.close(index);
                                        var milepostname = $("#selmilepost option:selected").text();
                                        var nodeOrder = $("#selmilepost option:selected").attr("layorder");
                                        var tabledata = layui.table.cache.payways;
                                        var _aln = tabledata.length;
                                        var currSppNo = data.sppNo;
                                        for (var i = 0; i < _aln; i++) {
                                            var _itm = tabledata[i];
                                            if ($("#selmilepost").val() == _itm.sppNode) {
                                                layer.msg("付款节点不允许重复", {icon: 2});
                                                return;
                                            }
                                            if (currSppNo > _itm.sppNo) {
                                                if (Number(nodeOrder) < Number(_itm.nodeOrder) && _itm.nodeOrder) {
                                                    layer.msg("选择的付款节点必须在前一个付款节点之后", {icon: 2});
                                                    return;
                                                }
                                            } else if (currSppNo < _itm.sppNo) {
                                                if (Number(nodeOrder) > Number(_itm.nodeOrder) && _itm.nodeOrder) {
                                                    layer.msg("选择的付款节点必须在后一个付款节点之前", {icon: 2});
                                                    return;
                                                }
                                            }

                                        }
                                        obj.update({
                                            milepostName: milepostname,
                                            nodeOrder: nodeOrder,
                                            sppNode: $("#selmilepost").val()
                                        });
                                    }
                                });
                                break;
                            case 'del':
                                layer.confirm('确定删除？', function (index) {

                                    var oldData = table.cache.payways;
                                    $.each(oldData, function (ind, item) {

                                        if (item.sppNo * 1 == obj.data.sppNo * 1) {
                                            oldData.splice(ind, 1);//删除缓存的行
                                            //跳出循环
                                            return false;
                                        }
                                    })
                                    $.each(oldData, function (ind, item) {
                                        item.sppNo = ind + 1;
                                    })
                                    table.reload("payways", {data: oldData})
                                    layer.close(index);
                                });
                                break;
                                case 'editStartDate':
                                    var field = $(this).data('field');
                                    if(!fksj){
                                    laydate.render({
                                        elem: this.firstChild
                                        , show: true //直接显示
                                        , closeStop: this
                                        , done: function (value, date) {
                                            data[field] = value;
                                            obj.update(data);
                                        }
                                    });
                                    }
                                    break;
                        }
                    },
                    edit: function (obj) {
                        if (obj.field == 'sppPersent') {
                            var per = obj.data.sppPersent;
                            if (per.indexOf("%") < 0) {
                                obj.update({
                                    sppPersent: per + "%"
                                });
                            }
                            var htMoney = $("#htMoney").val();
                            if (htMoney) {
                                var money = (htMoney * ((parseFloat(per.replace("%", ""))) / 100)).toFixed(2);
                                obj.update({
                                    payMoney: money
                                });
                            }
                            table.reload("payways", {data: table.cache.payways});
                        }

                    },
                    toolbar: function (obj) {
                        var checkStatus = table.checkStatus(obj.config.id);
                        switch (obj.event) {
                            case 'addrow':
                                var tabledata = table.cache.payways;
                                console.log(tabledata)
                                var _aln = tabledata.length + 1;
                                tabledata.push({
                                    "sppId": "10004",
                                    "sppNo": _aln,
                                    "sppNode": "",
                                    "nodeOrder": "",
                                    "milepostName": "",
                                    "payDate":"",
                                    "sppPersent": "",
                                    "payMoney": ""

                                });
                                table.reload("payways", {data: tabledata})
                                break;
                        }
                    }
                }
            },
            stages: {
                getmilestoneselects: function () {
                    //根据阶段设置 拿去里程碑 进度占比
                    var _yopts = [];
                    var indexno = 0;
                    //加个判断防止一些不必要的错误
                    $("#dvmilepost").find("input[type=checkbox]").each(function (i, v) {
                        if ($(v).prop('checked')) {
                            indexno++;
                            var mipostno = $(v).parent().next().attr("value");
                            _yopts.push('<option  layorder=' + indexno + ' value=' + mipostno + '>' + $(v).attr('mname') + '</option>');
                        }
                    })
                    return "<select id ='selmilepost' style='width:98%'>" + _yopts.join() + "</select>"
                },
                check: function () {
                    var start = document.getElementById("startDate").value;//获取起始日期
                    var end = document.getElementById("endDate").value;//获取结束日期
                    if (start == "") {
                        return;
                    } else if (end == "") {
                        return;
                    }
                    document.getElementById("totalDate").value = getDays(start, end);
                },
                getdays: function (startDate, endDate) {
                    var date1Str = startDate.split("-");//将日期字符串分隔为数组，数组元素分别为年、月、日
                    //根据年、月、日的值创建Date对象
                    var date1Obj = new Date(date1Str[0], (date1Str[1] - 1), date1Str[2]);
                    var date2Str = endDate.split("-");
                    var date2Obj = new Date(date2Str[0], (date2Str[1] - 1), date2Str[2]);
                    var t1 = date1Obj.getTime();//返回从1970-1-1开始计算到Date对象中的时间之间的毫秒数
                    var t2 = date2Obj.getTime();//返回从1970-1-1开始计算到Date对象中的时间之间的毫秒数
                    var datetime = 1000 * 60 * 60 * 24; //一天时间的毫秒值
                    var minusDays = Math.floor(((t2 - t1) / datetime));//计算出两个日期天数差
                    var days = Math.abs(minusDays);//如果结果为负数，取绝对值
                    return days;

                },
                loadStageMile: {
                    byProjectType: function (prjtype) {
                        layerAjaxGet('/jc/projectCreate/baseStage', {"projectTypeNo": prjtype}, '', function (d) {
                            var list = d.data;
                            if (d.flag == true) {

                                // 如果成功了 然后 就拼接阶段设置
                                if (d.data != null) {
                                    $("#zbjd").empty();
                                    $("#dvmilepost").find('ul').remove();
                                    var _lststgid = '';
                                    for (var i = 0; i < list.length; i++) {
                                        var _stg = list[i];
                                        var _stgid = _stg.id;
                                        var _mul = $("#dvmilepost").find("ul[pid=" + _stgid + "]");
                                        var _len = _mul.length;
                                        if (_len > 0) {
                                            var _mileLiEle = _crt_page.stages.loadStageMile.getmilepostLiElement(_stg);
                                            _mul.append(_mileLiEle);
                                        } else {
                                            var _stgliEle = _crt_page.stages.loadStageMile.getStageLiElement(_stg);
                                            _stgliEle.click(_crt_page.stages.loadStageMile.showmilepost);
                                            $("#zbjd").append(_stgliEle);
                                            var _mileul = $("<ul pid='" + _stgid + "' style='display: none'></ul>");
                                            var _mileLiEle = _crt_page.stages.loadStageMile.getmilepostLiElement(_stg);
                                            _mileul.append(_mileLiEle);
                                            $("#dvmilepost").append(_mileul);
                                        }
                                    }
                                    _crt_page.stages.loadStageMile._initStageDate();
                                    $("#zbjd").find('li:first').click();
                                    form.render('checkbox');
                                } else {
                                    layer.msg('返回数据为空', {icon: 2});
                                }
                                var code = $("#projectType").val();
                                ywlx(code);
                            } else {
                                layer.msg(d.msg, {icon: 2});
                            }
                        });
                    },
                    _initStageDate: function () {
                        lay('#stagebox .stagerq').each(function () {
                            var that = this;
                            laydate.render({
                                elem: this,
                                type: 'date',
                                trigger: 'click',
                                done: function (value, date) {
                                    var jd = $(this.elem[0]).attr('id');
                                    var zgqStart = $("#totalDurationBeginDate").val();
                                    if (!zgqStart) {
                                        layer.msg("请选择总工期开始时间", {总工期icon: 2});
                                        $(that).val("");
                                        return;
                                    }
                                    var zgqEnd = $("#totalDurationEndDate").val();
                                    if (!zgqEnd) {
                                        layer.msg("请选择总工期结束时间", {总工期icon: 2});
                                        $(that).val("");
                                        return;
                                    }
                                    if (jd == "zbBeginDate") {
                                        /*阶段开始时间*/
                                        if (value < zgqStart) {
                                            layer.msg("阶段的开始时间不能早于总工期开始时间", {总工期icon: 2});
                                            $(that).val("");
                                            return;
                                        }
                                        if (value > zgqEnd) {
                                            layer.msg("阶段的开始时间不能晚于总工期结束时间", {总工期icon: 2});
                                            $(that).val("");
                                            return;
                                        }
                                    }
                                    if (jd == "zbEndDate") {
                                        if (value < zgqStart) {
                                            layer.msg("阶段的结束时间不能早于总工期开始时间", {总工期icon: 2});
                                            $(that).val("");
                                            return;
                                        }
                                        if (value > zgqEnd) {
                                            layer.msg("阶段的结束时间不能晚于总工期结束时间", {总工期icon: 2});
                                            $(that).val("");
                                            return;
                                        }
                                        var jdbeginDate = $(that).parent().find("#zbBeginDate").val();
                                        if (value < jdbeginDate) {
                                            layer.msg("阶段结束时间不能早于阶段开始时间", {总工期icon: 2});
                                            $(that).val("");
                                            return;
                                        }
                                        if ($(that).parents("li").eq(0).next().length > 0) {
                                            /*不是最后一个阶段*/
                                            var date1Str = value.split("-");//将日期字符串分隔为数组，数组元素分别为年、月、日
                                            //根据年、月、日的值创建Date对象
                                            var date1Obj = new Date(date1Str[0], (date1Str[1] - 1), date1Str[2]);
                                            date1Obj.setDate(date1Obj.getDate() + 1);
                                            var year = date1Obj.getFullYear();
                                            var month = date1Obj.getMonth() + 1;
                                            var date = date1Obj.getDate();
                                            if (month < 10) {
                                                month = "0" + month;
                                            }
                                            if (date < 10) {
                                                date = "0" + date;
                                            }
                                            var datestrAdd = year + "-" + month + "-" + date;
                                            if (datestrAdd < zgqEnd || datestrAdd == zgqEnd) {
                                                /*获取*/
                                                $(that).parents("li").eq(0).next().find("#zbBeginDate").val(datestrAdd)
                                            }
                                        }
                                    }
                                }
                            });
                        });
                        /*设置默认值*/
                        var zgqStart = $("#totalDurationBeginDate").val();
                        if (zgqStart) {
                            $("#zbjd").find("li").first().find("#zbBeginDate").val(zgqStart);
                        }
                        var zgqEnd = $("#totalDurationEndDate").val();
                        if (zgqEnd) {
                            $("#zbjd").find("li").last().find("#zbEndDate").val(zgqEnd);
                        }

                    },
                    /*getCheckboxDisabled: function () {
                        var _chkShape = $("#checkShape").val();
                        if ((_chkShape == '002')) {
                            return "disabled";
                        } else {
                            return "";
                        }
                    },*/
                    getStageLiElement: function (stage) {
                        var _dsabled =false;
                        var sta = {
                            checkd: true,
                            stagename: stage.stageName,
                            milepostlist: []
                        };
                        stamil.push(sta);
                        var _i = $("#zbjd").find('li').length;
                        return $('<li class="clearfix" stageId="' + stage.id + '">' +
                            '<input type="checkbox" lay-filter="stage" class="fl clearfix" value="' + stage.id + '" name=""  lay-skin="primary"   checked ' + _dsabled + '/>' +
                            '<span>' + stage.orderNum + '.' + stage.stageName + '</span>' +
                            '<input type="hidden" class="zbstage" name="jcProjectStages[' + _i + '].id" value="' + stage.id + '">' +
                            '<input type="hidden" class="" name="jcProjectStages[' + _i + '].zbName" value="' + stage.stageName + '">' +
                            '<input type="hidden" class="" name="jcProjectStages[' + _i + '].stageNo" value="' + stage.stageNo + '">' +
                            '<input type="hidden" class="" name="jcProjectStages[' + _i + '].orderNum" value="' + stage.orderNum + '">' +
                            '<input type="hidden" class="open" name="jcProjectStages[' + _i + '].status" value="1">' +
                            '<div class="fr clearfix">' +
                            '<input type="text" class="fl stagerq" id="zbBeginDate"  autocomplete="off" lay-verify="required" name="jcProjectStages[' + _i + '].startDate" >' +
                            '<span class="fl">--</span>' +
                            '<input type="text" class="fl stagerq" id="zbEndDate"    autocomplete="off"     lay-verify="required" name="jcProjectStages[' + _i + '].endDate" />' +
                            '</div>' +
                            '</li>');
                    },
                    getmilepostLiElement: function (stage) {
                        var _dsabled =false;
                        var milobj = {
                            checkd: true,
                            num: stage.milepostZb,
                            milepostname: stage.milepostName
                        };
                        for (var i = 0; i < stamil.length; i++) {
                            if (stamil[i].stagename === stage.stageName) {
                                stamil[i].milepostlist.push(milobj)
                            }
                        }
                        var _i = $("#dvmilepost").find("li").length;
                        return $('<li class="clearfix">' +
                            '<span class="fl">' +
                            '<input type="checkbox" lay-filter="milepost" name="lcb"  lay-skin="primary" checked ' + _dsabled + ' mname="' + stage.milepostName + '" title="' + stage.milepostOrderNum + '.' + stage.milepostName + '"/>' +
                            '<input type="hidden" class="open" name="jcProjectMileposts[' + _i + '].status" value="1">' +
                            '</span>' +
                            '<input type="hidden" class="jdmilepostno" name="jcProjectMileposts[' + _i + '].milepostNo" value="' + stage.milepostCode + '">' +
                            '<input type="hidden" class="jdpercentage" name="jcProjectMileposts[' + _i + '].supervisorProjectStageId" value="' + stage.id + '">' +
                            '<input type="hidden" class="jdpercentage" name="jcProjectMileposts[' + _i + '].spmBaseMilePostId" value="' + stage.milepostId + '">' +
                            '<div class="fr">' +
                            '<input type="text" class="jdpercentage" name="jcProjectMileposts[' + _i + '].percentage" lay-maxlength="3"  lay-verify="perdecimal|maxlength" value="' + stage.milepostZb + '" style="width:80px;text-align: right"/>%' +
                            '</div>' +
                            '</li>');
                    },
                    showmilepost: function () {
                        var that = $(this);
                        var _stgid = that.attr('stageId');
                        that.parent().find('li').removeClass('selected');
                        that.addClass('selected')
                        $("#dvmilepost").find('ul').hide();
                        $("#dvmilepost").find("ul[pid=" + _stgid + "]").show();
                        _crt_page.events.displayMilepost();
                    }
                }
            },
            fzr: {
                _init: function () {
                     $('#btn_addfzr').click(_crt_page.fzr.addFuzeren);
                },
                addFuzeren: function () {
                    // 负责人下面有个分包  上面的分包写多少 就在这个下拉框的地方显示几个
                    var _len = $("#FZR .enterpriseUnitList").length;
                    $("#FZR").find(".center").before('<div class="enterpriseUnitList mbox"><div class="bold ft18">项目负责人<span class="fzrInd">' + ($("#FZR").find('.enterpriseUnitList').length + 1) + '</span><img src="${re.contextPath}/plugin/common/images/31@2x.png" onclick="_crt_page.fzr.del(this)"  alt="" class="fr cursor" style="width:13px"></div><ul class="clearfix mt20"><li class="clearfix"><label class="fl w120">项目负责人<span style="color: red">*</span></label><input type="text" class="fzr unit-ind-1" name="projectLeaders[' + (_len) + '].realName" lay-maxlength="128" lay-verify="required|maxlength" ><input type="hidden" class="fzr unit-ind-1" name="projectLeaders[' + (_len) + '].projectLeader"></li><li class="clearfix"><label class="fl">职务<span style="color: red">*</span></label><input type="text" class="zw unit-ind-1" name="projectLeaders[' + (_len) + '].duty" lay-maxlength="128" lay-verify="required|maxlength" ></li></ul></div> ');
                    // _crt_page.forms.selects._intSlt(_len, 'slt');
                },
                del: function (object) {
                    var _len = $("#FZR .enterpriseUnitList").length;
                    if(_len == 1){
                        layer.msg("不能全部删除", {icon: 2});
                        return;
                    }
                    $(object).parent().parent().remove();
                    _crt_page.fzr.formatFzrInd();
                    _crt_page.fzr.formatFzrselectInd();
                },
                formatFzrInd: function () {
                    lay('#FZR .enterpriseUnitList').each(function (ind, obj) {
                        $(obj).find('.fzrInd').text(ind + 1);
                        var unitInd1s = $(obj).find('.unit-ind-1');
                        if (unitInd1s) {
                            var begin = 0;
                            _crt_page.units.formatFieldIndex(unitInd1s, begin, unitInd1s.length, ind);
                        }

                    });
                },
                formatFzrselectInd: function () {
                    $("#FZR").find(".slt").each(function (i, v) {
                        $(v).attr("id", "slt" + i);
                    });
                }
            },

            bcUnit: {
                _init: function () {
                    $('#btn_addBcUnit').click(_crt_page.bcUnit.addBcUnit);
                },
                addBcUnit: function () {
                    var _len = $("#BcUnit .enterpriseUnitList").length;
                    $("#BcUnit").find(".center").before('<div class="enterpriseUnitList mbox"><div class="bold ft18">承建单位<span class="fzrInd">' + ($("#BcUnit").find('.enterpriseUnitList').length + 1) + '</span><img src="${re.contextPath}/plugin/common/images/31@2x.png" onclick="_crt_page.bcUnit.del(this)"  alt="" class="fr cursor" style="width:13px"></div><ul class="clearfix mt20"><li class="clearfix"><label class="fl" style="width: 32%!important;">承建负责人<span style="color: red">*</span></label><input type="text" class="fzr unit-ind-1" name="bcList[' + (_len) + '].bcUnitNo" lay-maxlength="128" lay-verify="required|maxlength" ><input type="hidden" class="fzr unit-ind-1" name="bcList[' + (_len) + '].id"></li><li class="clearfix"><label class="fl">承建单位<span style="color: red">*</span></label><input type="text" class="zw unit-ind-1" name="bcList[' + (_len) + '].bcUnit" lay-maxlength="128" lay-verify="required|maxlength" ></li><li class="clearfix">'+
                        '<label class="fl" style = "width:150px">被测合同/系统名称<span style="color: red">*</span></label>'+
                        ' <input type="text" class="fl unit-ind-1" lay-maxlength="128" name="bcList[' + (_len) + '].bcHtName"'+
                        '   lay-verify="required|maxlength">'+
                        ' </li></ul></div> ');
                    // _crt_page.forms.selects._intSlt(_len, 'slt');
                },
                del: function (object) {
                    var _len = $("#FZR .enterpriseUnitList").length;
                    if(_len == 1){
                        layer.msg("不能全部删除", {icon: 2});
                        return;
                    }
                    $(object).parent().parent().remove();
                    _crt_page.bcUnit.formatFzrInd();
                    _crt_page.bcUnit.formatBcUnitselectInd();
                },
                formatFzrInd: function () {
                    lay('#BcUnit .enterpriseUnitList').each(function (ind, obj) {
                        $(obj).find('.fzrInd').text(ind + 1);
                        var unitInd1s = $(obj).find('.unit-ind-1');
                        if (unitInd1s) {
                            var begin = 0;
                            _crt_page.units.formatFieldIndex(unitInd1s, begin, unitInd1s.length, ind);
                        }

                    });
                },
                formatBcUnitselectInd: function () {
                    $("#BcUnit").find(".slt").each(function (i, v) {
                        $(v).attr("id", "slt" + i);
                    });
                }
            },



























            units: {
                del: function (object) {
                    $(object).parent().parent().remove();
                    _crt_page.units.formatUnitsIndSelect();
                },
                //格式化里面的下标
                formatFieldIndex: function (inds, begin, length, target) {
                    var aObj = inds[begin];
                    if (aObj) {
                        var name = $(aObj).attr('name');
                        if (name) {
                            reg = new RegExp('\\[(.+?)\\]', "g");
                            var newName = name.replace(reg, '[' + target + ']');
                            $(aObj).attr('name', newName);
                        }
                    }
                    begin++;
                    if (begin < length) {
                        _crt_page.units.formatFieldIndex(inds, begin, length, target);
                    }
                }
            },
            pays: {
                _init: function () {
                    $('#buyType').chage(_crt_page.pays.addPayCount);
                },
                addPayCount: function () {
                    var _len = 0;
                    var pc = $("#buyType  option:selected").text();
                    var payCount = [];
                    // 如果有值就是分包值  如果没值 就是1
                    pc = pc ? pc : 1;
                    for (var i = 1; i <= pc; i++) {
                        _len++;
                        $("#payId").before('<div class="clearfix" >\n' +
                            '<label class="fl" >第' + (_len) + '次付款方式</label>\n' +
                            '<select class="fl" id="payType" name="payCount' + (_len) + '" value="' + (_len) + '">\n' +
                            '<option value="">请选择</option><#list payList as vo><option value="${vo.badtCode}">${vo.badtName}</option>' +
                            '</#list></select></div>'
                        );
                    }
                }
            },
            events: {
                _init: function () {
                    $("#province").change(_crt_page.events.province);
                    $("#city").change(_crt_page.events.city);
                    $("#projectType").change(_crt_page.events.projecttype);
                    $("#checkShape").change(_crt_page.events.supervisiorform);
                },
                sourceSelectChange: function (object) {
                    var code = $(object).val();
                    if (code == "002") {
                        $(".selectpro").css('display', 'block');
                    } else {
                        $(".selectpro").css('display', 'none');
                    }
                    //清空值
                    $("input").val("");
                    $("input").attr("readonly", false);
                    $("#biddingRequired").removeAttr("disabled");
                    $("#hasInviteBids").removeAttr("disabled");
                    $("#hasContractSigned").removeAttr("disabled");
                    $("#hasDownPayment").removeAttr("disabled");
                    $("#contractNo").attr("readonly", false);
                    $("#jlHtName").attr("readonly", false);
                    $("#payOrProjectNo").attr("readonly", false);
                    $("#checkShape").removeAttr("disabled");
                    $("#contractSignTime").attr("disabled",false);
                    $("select").removeAttr("disabled");
                    $("select").find("option").each(function (i, v) {
                        $(v).attr("selected", false);
                    });
                    _crt_page.forms.selects._intSlt(0, 'slt');
                    _crt_page.events.placeInit();

                },
                toDate: function (object) {
                    var code = $(object).val();
                    if (code == "1") {
                        _crt_page.tables.renderTable(false,true);
                    } else {
                        _crt_page.tables.renderTable(true,false);
                    }
                    var htMoney = $("#htMoney").val();
                    var money = htMoney;
                    if (money) {
                        var tabledata = table.cache.payways;
                        for (var j = 0; j < tabledata.length; j++) {
                            var sppPersent = tabledata[j].sppPersent;
                            if (sppPersent) {
                                var payM = (money * ((parseFloat(sppPersent.replace("%", ""))) / 100)).toFixed(2);
                                tabledata[j].payMoney = payM;
                            }
                        }
                    }
                    table.reload("payways", {data: tabledata});
                },
                toHetong: function (object) {
                    var code = $(object).val();
                    if(code == "0"){
                        $("#hetongDiv").css("display","none");
                    }else{
                        $("#hetongDiv").css('display', 'block');
                    }
                },
                toZhaoBiao: function (object) {
                    var code = $(object).val();
                    if(code == "0"){
                        $("#zhaobiaoDiv").css("display","none");
                    }else{
                        $("#zhaobiaoDiv").css('display', 'block');
                    }
                },
                toDate2: function (object) {

                    var code = $(object).val();
                    var date = $("#totalDurationBeginDate").val();
                    if(date == null || date == "" || date == undefined){
                        return;
                    }
                    var re = /^[0-9]*[1-9][0-9]*$/ ;
                    if(!(re.test(code))){
                        layer.msg("请输入正整数", {icon: 2});
                        $(object).val("");
                        return;
                    }
                    var day = DateDiff2(date,code);
                    $("#totalDurationEndDate").val(day);
                    $("#zbjd").find("li").last().find("#zbEndDate").val(day)
                    $("#zbjd").find("li").first().find("#zbBeginDate").val(date)
                },
                provinceChange: function (object) {
                    var code = $(object).find('option:selected').val();
                    if (code == "") {
                        return;
                    }
                    layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
                        if (d.flag == true) {
                            $(object).next().empty().append("<option value=''>选择市</option>");
                            for (var i = 0; i < d.data.length; i++) {
                                $(object).next().append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                            }
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });
                },
                addPlace: function (object) {
                    $(object).parent().after(" <div class=\"clearfix mt10 divplaceselect\">\n" +
                        "                            <select name=\"projectPlacedtos[1].province\" class=\"ml8 fl\" id=\"placeprovince1\"   onchange=\"_crt_page.events.provinceChange(this)\"  style=\"width:90px !important;\"\n" +
                        "                                    lay-verify=\"required\" lay-ignore>\n" +
                        "                                <option value=\"\">请选择</option>\n" +
                        "                                <#list provincelist as vo>\n" +
                        "                                    <option value=\"${vo.code}\">${vo.name}</option>\n" +
                        "                                </#list>\n" +
                        "                            </select>\n" +
                        "                            <select name=\"projectPlacedtos[1].city\" id=\"placecity1\" class=\"ml8 fl\"  onchange=\"_crt_page.events.cityChange(this)\" lay-filter=\"projectPlacedtos[1].city\" lay-verify=\"required\"\n" +
                        "                                    style=\"width: 90px !important;margin-left: 10px\" lay-ignore>\n" +
                        "                                <option value=\"\">请选择</option>\n" +
                        "                            </select>\n" +
                        "                            <select name=\"projectPlacedtos[1].county\" id=\"placecounty1\" class=\"ml8 fl\" lay-filter=\"projectPlacedtos[1].county\" lay-verify=\"required\"\n" +
                        "                                    style=\"width:90px !important;margin-left: 10px\" lay-ignore>\n" +
                        "                                <option value=\"\">请选择</option>\n" +
                        "                            </select>\n" +
                        "                            <img src=\"${re.contextPath}/plugin/common/images/77@2x.png\" class=\"fl ml20 addplaceimage\" style=\"width: 28px;\" onclick=\"_crt_page.events.addPlace(this)\" >\n" +
                        "                            <img src=\"${re.contextPath}/plugin/common/images/76@2x.png\" class=\"fl ml20\"  style=\"width: 28px;\" onclick=\"_crt_page.events.deletePlace(this)\">\n" +
                        "                        </div>");
                    _crt_page.events.resetPlace();

                },
                resetPlace: function () {
                    /*  $(".ssplace").find(".addplaceimage:not(:last)").attr("style","display:none;")*/
                    $(".ssplace").find(".divplaceselect").each(function (i, v) {
                        $(v).find("select:eq(0)").attr("name", "projectPlacedtos[" + i + "].province")
                        $(v).find("select:eq(1)").attr("name", "projectPlacedtos[" + i + "].city");
                        $(v).find("select:eq(2)").attr("name", "projectPlacedtos[" + i + "].county");
                        $(v).find("select:eq(0)").attr("lay-filter", "projectPlacedtos[" + i + "].province");
                        $(v).find("select:eq(1)").attr("lay-filter", "projectPlacedtos[" + i + "].city");
                        $(v).find("select:eq(2)").attr("lay-filter", "projectPlacedtos[" + i + "].county");
                    });
                },
                deletePlace: function (object) {
                    var placeLength = $(".ssplace").find(".divplaceselect").length;
                    if (placeLength == 1) {
                        layer.msg("实施地点不能全部删除", {icon: 2});
                    } else {
                        $(object).parent().remove();
                        _crt_page.events.resetPlace();
                    }

                },
                cityChange: function (object) {
                    var code = $(object).find('option:selected').val();
                    if (code == "") {
                        return;
                    }
                    layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
                        if (d.flag == true) {
                            $(object).next().empty().append("<option value=''>选择区县</option>");
                            for (var i = 0; i < d.data.length; i++) {
                                $(object).next().append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                            }
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });

                },

                province: function () {
                    var code = $('#province option:selected').val();
                    if (code == "") {
                        return;
                    }
                    layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
                        if (d.flag == true) {
                            $("#city").empty().append("<option value=''>选择市</option>");
                            for (var i = 0; i < d.data.length; i++) {
                                $("#city").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");

                            }
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });


                },
                provinceval: function () {
                    var code = $('#province option:selected').val();
                    if (code == "") {
                        return;
                    }
                    layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
                        if (d.flag == true) {
                            $("#city").empty().append("<option value=''>选择市</option>");
                            for (var i = 0; i < d.data.length; i++) {
                                var htSignCity = $("#htSignCity").val();
                                if (htSignCity == d.data[i].code) {
                                    $("#city").append("<option value='" + d.data[i].code + "' selected=\"selected\">" + d.data[i].name + "</option>");
                                } else {
                                    $("#city").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                                }

                            }
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });


                },
                cityval: function () {
                    var code = $('#city option:selected').val();
                    if (code == "") {
                        return;
                    }
                    layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
                        if (d.flag == true) {
                            $("#county").empty().append("<option value=''>选择区县</option>");
                            for (var i = 0; i < d.data.length; i++) {
                                var htSignCounty = $("#htSignCounty").val();
                                if (htSignCounty == d.data[i].code) {
                                    $("#county").append("<option value='" + d.data[i].code + "' selected=\"selected\">" + d.data[i].name + "</option>");
                                } else {
                                    $("#county").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                                }

                            }
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });


                },
                city: function () {
                    var code = $('#city option:selected').val();
                    if (code == "") {
                        return;
                    }
                    layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
                        if (d.flag == true) {
                            $("#county").empty().append("<option value=''>选择区县</option>");
                            for (var i = 0; i < d.data.length; i++) {
                                $("#county").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                            }
                        } else {
                            layer.msg(d.msg, {icon: 2});
                        }
                    });


                },
                gxPlaceInit:function(palaces){
                    var str = "";
                    for (var i = 0; i < palaces.length; i++) {
                        var palace = palaces[i];
                        console.log(palace);
                        var city = palace.city;
                        var citys = palace.citys;
                        var province = palace.province;
                        var county = palace.county;
                        var countys = palace.countys;
                        str = str + "<div class=\"clearfix mt10 divplaceselect\">\n" +
                            "                                    <select name=\"projectPlacedtos[" + i + "].province\" class=\"ml8 fl\" id=\"placeprovince0\"  onchange=\"_crt_page.events.provinceChange(this)\" style=\"width:90px !important;\"\n" +
                            "                                            lay-verify=\"required\" lay-ignore>\n" +
                            "                                        <option value=\"\">请选择</option>\n" +
                            "                                        <#list provincelist as vo>\n" +
                            "                                            <option value=\"${vo.code}\"\n";
                        if (province == "${vo.code}") {
                            str = str + "   selected\n";
                        }
                        str = str + "  >${vo.name}</option>\n" +
                            "                                        </#list>\n" +
                            "                                    </select>\n" +
                            "                 <select name=\"projectPlacedtos[" + i + "].city\"  id=\"placecity0\" class=\"ml8 fl\" lay-filter=\"city\" onchange=\"_crt_page.events.cityChange(this)\" lay-verify=\"required\"\n" +
                            "                                            style=\"width: 90px !important;margin-left: 10px\" lay-ignore>\n" +
                            "                                        <option value=\"\">请选择</option>\n";
                        for (var j = 0; j < citys.length; j++) {
                            var code = citys[j].code;
                            var name = citys[j].name;
                            str = str + " <option value=" + code + "";
                            if (city == code) {
                                str = str + "   selected\n";
                            }
                            str = str + " >" + name + "</option>";
                        }
                        str = str + "   </select>" +
                            "         <select name=\"projectPlacedtos[" + i + "].county\" id=\"placecounty0\" class=\"ml8 fl\" lay-filter=\"county\" lay-verify=\"required\"\n" +
                            "                                            style=\"width:90px !important;margin-left: 10px\" lay-ignore>\n" +
                            "                                        <option value=\"\">请选择</option>\n";
                        for (var j = 0; j < countys.length; j++) {
                            var code = countys[j].code;
                            var name = countys[j].name;
                            str = str + " <option value=" + code + "";
                            if (county == code) {
                                str = str + "   selected\n";
                            }
                            str = str + " >" + name + "</option>";
                        }

                        str = str + "      </select>"
                        str = str + "                                <img src=\"${re.contextPath}/plugin/common/images/77@2x.png\" style=\"width: 28px;\"\n" +
                            "                                             class=\"fl ml20 addplaceimage\" onclick=\"_crt_page.events.addPlace(this)\">\n" +
                            "                                        <img src=\"${re.contextPath}/plugin/common/images/76@2x.png\" style=\"width: 28px;\"\n" +
                            "                                             class=\"fl ml20\"\n" +
                            "                                             onclick=\"_crt_page.events.deletePlace(this)\">\n";
                        str = str + "  </div>";
                    }
                    $(".ssplace").html(str);
                },
                placeInit:function(palaces){
                    var str = "     " +
                        "                                    <div class=\"clearfix mt10 divplaceselect\" style=\"width: 100%;\">\n" +
                        "                                        <select name=\"projectPlacedtos[0].province\" class=\"ml8 fl\" id=\"placeprovince0\"\n" +
                        "                                                onchange=\"_crt_page.events.provinceChange(this)\"\n" +
                        "                                                style=\"width:90px !important;\"\n" +
                        "                                                lay-verify=\"required\" lay-ignore>\n" +
                        "                                            <option value=\"\">请选择</option>\n" +
                        "                                            <#list provincelist as vo>\n" +
                        "                                                <option value=\"${vo.code}\">${vo.name}</option>\n" +
                        "                                            </#list>\n" +
                        "                                        </select>\n" +
                        "                                        <select name=\"projectPlacedtos[0].city\" id=\"placecity0\" class=\"ml8 fl\"\n" +
                        "                                                lay-filter=\"city\"\n" +
                        "                                                onchange=\"_crt_page.events.cityChange(this)\" lay-verify=\"required\"\n" +
                        "                                                style=\"width: 90px !important;margin-left: 10px\" lay-ignore>\n" +
                        "                                            <option value=\"\">请选择</option>\n" +
                        "                                        </select>\n" +
                        "                                        <select name=\"projectPlacedtos[0].county\" id=\"placecounty0\" class=\"ml8 fl\"\n" +
                        "                                                lay-filter=\"county\" lay-verify=\"required\"\n" +
                        "                                                style=\"width:90px !important;margin-left: 10px\" lay-ignore>\n" +
                        "                                            <option value=\"\">请选择</option>\n" +
                        "                                        </select>\n" +
                        "                                        <img src=\"${re.contextPath}/plugin/common/images/77@2x.png\" style=\"width: 28px;\"\n" +
                        "                                             class=\"fl ml20 addplaceimage\" onclick=\"_crt_page.events.addPlace(this)\">\n" +
                        "                                        <img src=\"${re.contextPath}/plugin/common/images/76@2x.png\" style=\"width: 28px;\"\n" +
                        "                                             class=\"fl ml20\"\n" +
                        "                                             onclick=\"_crt_page.events.deletePlace(this)\">\n" +
                        "                                    </div>\n";
                    $(".ssplace").html(str);
                },
                projecttype: function () {
                    var projectTypeNo = $("#projectType option:selected").val();
                    _crt_page.stages.loadStageMile.byProjectType(projectTypeNo);
                },
                supervisiorform: function () {
                    var _dsabled =false;
                    if (_dsabled != '') {
                        $("#stagebox").find("input[type=checkbox]").attr("disabled", "disabled").attr("checked", "checked");
                        $("#stagebox").find("input[type=checkbox]").next().addClass('layui-form-checked');
                        $("#stagebox .stageRt").find("input[type=text]").attr("readOnly", "readOnly");
                        $("#stagebox").find(".open").attr("value", "1");
                    } else {
                        $("#stagebox").find("input[type=checkbox]").removeAttr("disabled");
                        $("#stagebox").find("input[type=checkbox]").next().removeClass('layui-checkbox-disbaled layui-disabled');
                        $("#stagebox .stageRt").find("input[type=text]").removeAttr("readOnly");
                    }
                },
                displayMilepost: function () {
                    /*初始化付款金额*/
                    var htMoney = $("#htMoney").val();
                    if (htMoney) {
                        var tabledata = table.cache.payways;
                        for (var j = 0; j < tabledata.length; j++) {
                            var sppPersent = tabledata[j].sppPersent;
                            if (sppPersent) {
                                var payM = (htMoney * ((parseFloat(sppPersent.replace("%", ""))) / 100)).toFixed(2);
                                tabledata[j].payMoney = payM;
                            }
                        }
                    }
                    table.reload("payways", {data: tabledata});

                    //动态设置'监理实施细则'里程的显示:
                    var stages = $("#zbjd").find('li');
                    var i = stages.length;
                    if (i > 0) {
                        var stageO = 0;
                        _crt_page.events.handleStage(stages, 0, i);
                    }
                }, handleStage: function (stages, i, end) {
                    var aLi = stages[i];
                    var stageId = $(aLi).find('.zbstage').val();
                    var milepostCodes = $("#dvmilepost").find(".jdmilepostno");
                    if (milepostCodes.length > 0) {
                        _crt_page.events.handleMilepost(aLi, milepostCodes, 0, milepostCodes.length);
                    }
                    i++;
                    if (i < end) {
                        _crt_page.events.handleStage(stages, i, end);
                    }
                }, handleMilepost: function (aLi, milepostCodes, i, end) {
                    <#--if (($(milepostCodes[i]).val() == '${jlssxzMilepost}') || ($(milepostCodes[i]).val() == '${jlssxzMilepost2}')) {-->
                    <#--    if ($('#htMoney').val() * 1 > '${supervisorContractQuota}' * 1) {-->
                    <#--        $(milepostCodes[i]).parent().find('input').removeAttr('disabled');-->
                    <#--        $(milepostCodes[i]).prev().find('input').attr('disabled', 'disabled');-->
                    <#--        if ($(aLi).hasClass("selected")) {-->
                    <#--            $(milepostCodes[i]).parent().show();-->
                    <#--        }-->
                    <#--        $.each($(milepostCodes[i]).parent().find('input'), function (e) {-->
                    <#--            var oldname = $(this).attr('oldname');-->
                    <#--            $(this).attr('name', oldname);-->
                    <#--            $(this).removeAttr('oldname');-->
                    <#--        })-->
                    <#--    } else {-->
                    <#--        $(milepostCodes[i]).parent().find('input').attr('disabled', 'disabled');-->
                    <#--        if ($(aLi).hasClass("selected")) {-->
                    <#--            $(milepostCodes[i]).parent().hide();-->
                    <#--        }-->
                    <#--        $.each($(milepostCodes[i]).parent().find('input'), function (e) {-->
                    <#--            var name = $(this).attr('name');-->
                    <#--            $(this).attr('oldname', name);-->
                    <#--            $(this).removeAttr('name');-->
                    <#--        })-->
                    <#--    }-->
                    <#--}-->
                    i++;
                    if (i < end) {
                        _crt_page.events.handleMilepost(aLi, milepostCodes, i, end);
                    }
                }
            }
        }
        _crt_page._init();
    });
    function resetRequired(){
        form.verify({
            required: function(v){

            }
        })
    }
    function resetRequiredSubmit(){
        form.verify({
            required: function(v){
                if(v == ""){
                    return "必填项不能为空";
                }
            }
        })
    }
    function tzym(){
        window.parent._delTabT('4cd21f6e7f1c4c0bab9ba5bb15ff2bb4');
        window.parent._showtab('4cd21f6e7f1c4c0bab9ba5bb15ff2bb4', '管理项目', '/jc/projectManager/projectIndex');
        window.parent._delTabT('28bbd38b9e234b34833f79b5de093a0e');
    }
    function ywlx(code){
        layerAjaxGet('/sys/register/getYw', {"code": code}, '', function (data) {
            var rows = null;
            var _ycols = ['badtCode', 'badtName'];
            if (data.flag) {
                if (data.data) {
                    rows = data.data;
                }
                if (rows) {
                    var yw = [];
                    $.each(rows, function (i, v) {
                        if (i == 0) {
                            yw.push({name: v[_ycols[1]], value: v[_ycols[0]], selected: true});
                        } else {
                            yw.push({name: v[_ycols[1]], value: v[_ycols[0]]});
                        }
                    })
                    // 绑定技术负责人下拉
                    xmselectyw = xmSelect.render({
                        el: '#checkShape',
                        filterable: true,
                        clickClose:true,
                        toolbar: {show: true},
                        layVerType: 'msg',
                        data: yw
                    })
                }
            }
        })
    }

</script>
</body>
</html>
